<template>
  <div class="myDiv">
    <Header title="日收入统计"></Header>
    <el-table
      :data="vesssel"
      v-loading="loading"
      border
      style="width: 100%;"
      size="mini"
      height="445"
    >
      <el-table-column fixed align="center" show-overflow-tooltip width="89" label="日期">
        <template slot-scope="scope">{{scope.row.orderTime.split(",")[0]}}</template>
      </el-table-column>
      <el-table-column show-overflow-tooltip prop="orderTotalprice" align="center" label="总收入"></el-table-column>
      <el-table-column show-overflow-tooltip prop="idcode" align="center" label="微信收入"></el-table-column>
      <el-table-column show-overflow-tooltip prop="userid" width="81" align="center" label="支付宝收入"></el-table-column>
      <el-table-column show-overflow-tooltip prop="openid" width="70" align="center" label="其他收入"></el-table-column>
    </el-table>
    <Page :total="total" @pagenum="pagenum" class="page"></Page>
  </div>
</template>

<script>
import Header from "@/components/header";
import Page from "@/components/pagination";
export default {
  components: { Header, Page },
  props: {},
  data() {
    return {
      datas: [],
      page: 1,
      rows: 15,
      total: 0,
      loading: true,
      tableData: [], //全部数据
      vesssel: [] //页面临时数据
    };
  },
  watch: {
    page: function() {
      if (this.page == 1) {
        this.vesssel = this.tableData.slice(0, this.rows);
      } else if (this.page == Math.ceil(this.tableData.length / 15)) {
        this.vesssel = this.tableData.slice((this.page - 1) * this.rows);
      } else {
        this.vesssel = this.tableData.slice(
          (this.page - 1) * this.rows,
          this.rows * this.page
        );
      }
    }
  },
  computed: {},
  methods: {
    pagenum(data) {
      this.page = data[0];
      this.rows = 15;
    }
  },
  created() {
    if (this.$route.query.data) {
      this.tableData = this.$route.query.data;
      this.total = this.$route.query.data.length;
      this.loading = false;
      this.vesssel = this.tableData.slice(0, this.rows);
    }
  },
  mounted() {}
};
</script>
<style scoped>
</style>